package com.deer.wms.ware.task.service.impl;

import com.deer.wms.project.root.util.DateUtils;
import com.deer.wms.ware.task.dao.StatisticsMapper;
import com.deer.wms.ware.task.model.Return.TopStatisticsDto;
import com.deer.wms.ware.task.model.SO.SoMaster;
import com.deer.wms.ware.task.model.statistics.TopStatisticsRequest;
import com.deer.wms.ware.task.service.SoMasterService;
import com.deer.wms.ware.task.service.StatisticsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

@Service
public class StatisticsServiceImpl implements StatisticsService {

    @Resource
    private StatisticsMapper statisticsMapper;

    @Override
    public TopStatisticsDto topStatistics(TopStatisticsRequest request) {
//        Integer days = request.getDays() == null ? 0 : request.getDays();
//        if (days != null) {
//            request.setEndTime(DateUtils.getNowDateTimeString());
//            request.setStartTime(DateUtils.dateToStr(DateUtils.getDateStartTime(DateUtils.addDay(new Date(), -days)), DateUtils.DEFAULT_DATETIME_FORMAT));
//        }
        TopStatisticsDto topStatisticsDto = statisticsMapper.topSoStatistics(request);
        TopStatisticsDto topStatisticsDto1 = statisticsMapper.topAcceptStatistics(request);
        topStatisticsDto.setAcceptCount(topStatisticsDto1.getAcceptCount());
        TopStatisticsDto topStatisticsDto2 = statisticsMapper.topAcceptExStatistics(request);
        topStatisticsDto.setQcCount(topStatisticsDto2.getQcCount());
        return topStatisticsDto;
    }

}
